<?xml version="1.0" encoding="UTF-8"?>
<as:AppSchemaDataAccess xmlns:as="http://www.geotools.org/app-schema"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.geotools.org/app-schema AppSchemaDataAccess.xsd">
	<namespaces>
		<Namespace>
			<prefix>om</prefix>
			<uri>http://www.opengis.net/om/2.0</uri>
		</Namespace>
		<Namespace>
			<prefix>gml</prefix>
			<uri>http://www.opengis.net/gml/3.2</uri>
		</Namespace>
		<Namespace>
			<prefix>wml2dr</prefix>
			<uri>http://www.opengis.net/waterml/DR/2.0</uri>
		</Namespace>
		<Namespace>
			<prefix>xlink</prefix>
			<uri>http://www.w3.org/1999/xlink</uri>
		</Namespace>
		<Namespace>
			<prefix>gmlcov</prefix>
			<uri>http://www.opengis.net/gmlcov/1.0</uri>
		</Namespace>
	</namespaces>
	<sourceDataStores>
		<DataStore>
			<id>properties</id>
			<parameters>
				<Parameter>
					<name>directory</name>
					<value>file:./</value>
				</Parameter>
			</parameters>
		</DataStore>
	</sourceDataStores>
	<catalog>wml2dr_catalog.xml</catalog>
	<targetTypes>
		<FeatureType>		
			<schemaUri>http://schemas.opengis.net/waterml/DR/2.0/timeseries-domain-range.xsd</schemaUri>
			<schemaUri>http://schemas.opengis.net/om/2.0/observation.xsd</schemaUri>
		</FeatureType>
	</targetTypes>
	<typeMappings>
		<FeatureTypeMapping>
			<sourceDataStore>properties</sourceDataStore>
			<sourceType>timeseries</sourceType>
			<targetElement>
				om:OM_Observation
			</targetElement>
			<attributeMappings>
				<AttributeMapping>
					<targetAttribute>om:OM_Observation</targetAttribute>
					<idExpression>
						<OCQL>ID</OCQL>
					</idExpression>
				</AttributeMapping>
				<AttributeMapping>
					<targetAttribute>om:phenomenonTime/gml:TimePeriod</targetAttribute>
					<!-- Workaround as gml:id is not appearing with idExpression -->
					<ClientProperty>
						<name>gml:id</name>
						<value>strConcat('TP.', ID)</value>
					</ClientProperty>
				</AttributeMapping>
				<AttributeMapping>
					<targetAttribute>om:phenomenonTime/gml:TimePeriod/gml:beginPosition</targetAttribute>
					<sourceExpression>
						<OCQL>POSITION</OCQL>
					</sourceExpression>
				</AttributeMapping>
				<AttributeMapping>
					<targetAttribute>om:phenomenonTime/gml:TimePeriod/gml:endPosition</targetAttribute>
					<sourceExpression>
						<OCQL>POSITION</OCQL>
						<index>LAST</index>
					</sourceExpression>
				</AttributeMapping>
				<AttributeMapping>
					<targetAttribute>om:result</targetAttribute>
					<targetAttributeNode>wml2dr:MeasurementTimeseriesCoveragePropertyType</targetAttributeNode>
				</AttributeMapping>
				<AttributeMapping>
					<targetAttribute>om:result/wml2dr:MeasurementTimeseriesDomainRange</targetAttribute>
					<!-- Workaround as gml:id is not appearing with idExpression -->
					<ClientProperty>
						<name>gml:id</name>
						<value>strConcat('measurement.', ID)</value>
					</ClientProperty>
				</AttributeMapping>
				<AttributeMapping>
					<targetAttribute>om:result/wml2dr:MeasurementTimeseriesDomainRange/gml:coverageFunction/gml:MappingRule</targetAttribute>
					<sourceExpression>
						<OCQL>'string'</OCQL>
					</sourceExpression>
				</AttributeMapping>
				<AttributeMapping>
					<targetAttribute>om:result/wml2dr:MeasurementTimeseriesDomainRange/gmlcov:rangeType</targetAttribute>
					<ClientProperty>
						<name>xlink:href</name>
						<value>'http://ns.bgs.ac.uk/thesaurus/lithostratigraphy'</value>
					</ClientProperty>
				</AttributeMapping>
				<AttributeMapping>
					<targetAttribute>om:result/wml2dr:MeasurementTimeseriesDomainRange/gml:domainSet</targetAttribute>
					<targetAttributeNode>wml2dr:TimePositionListPropertyType</targetAttributeNode>
				</AttributeMapping>
				<AttributeMapping>
					<targetAttribute>om:result/wml2dr:MeasurementTimeseriesDomainRange/gml:domainSet/wml2dr:TimePositionList</targetAttribute>
					<idExpression>
						<OCQL>strConcat('tpl.', ID)</OCQL>
					</idExpression>
				</AttributeMapping>
				<AttributeMapping>
					<targetAttribute>om:result/wml2dr:MeasurementTimeseriesDomainRange/gml:domainSet/wml2dr:TimePositionList/wml2dr:timePositionList</targetAttribute>
					<sourceExpression>
						<OCQL>POSITION</OCQL>
					</sourceExpression>
					<isList>true</isList>
				</AttributeMapping>
				<AttributeMapping>
					<targetAttribute>om:result/wml2dr:MeasurementTimeseriesDomainRange/gml:rangeSet/gml:QuantityList</targetAttribute>
					<sourceExpression>
						<OCQL>RANGE</OCQL>
					</sourceExpression>
					<isList>true</isList>
					<ClientProperty>
						<name>uom</name>
						<value>'degC'</value>
					</ClientProperty>
				</AttributeMapping>
			</attributeMappings>
		</FeatureTypeMapping>
	</typeMappings>
</as:AppSchemaDataAccess>
